IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[prc_HP_BenhNhan]') AND type in (N'P', N'PC'))
   DROP PROCEDURE [dbo].[prc_HP_BenhNhan]

GO


Create Proc prc_HP_BenhNhan

@Action varchar(200) = '',
@BacSiID varchar(50) = '',
@BenhNhanID varchar(50) = '',
@CanNang float = -1,
@ChieuCao float = -1,
@ChiNhanhID varchar(50) = '',
@Date_Add smalldatetime = '2011/03/15',
@Date_Up smalldatetime = '2011/03/15',
@DenPhong varchar(50) = '',
@DiaChi nvarchar(200) = '',
@DienGiai nvarchar(200) = '',
@DienThoai varchar(20) = '',
@DoiTuongKham varchar(5) = '',
@GioiTinh varchar(1) = '',
@HanSDDen datetime = '2011/03/15',
@HanSDTu datetime = '2011/03/15',
@HoTenLot nvarchar(200) = '',
@HoVaTen nvarchar(200) = '',
@HuyetAp varchar(50) = '',
@LoaiTuoi varchar(1) = '',
@Mach float = -1,
@MaSoTheKCB nvarchar(50) = '',
@NgayKCB datetime = '2011/03/15',
@NgaySinh datetime = '2011/03/15',
@NgheNghiepID varchar(50) = '',
@NhietDo float = -1,
@NhipTho float = -1,
@NoiDKKCB nvarchar(200) = '',
@PhongID varchar(50) = '',
@QuanHeID varchar(50) = '',
@Scrn_Add nvarchar(50) = '',
@Scrn_Up nvarchar(50) = '',
@SoCM nvarchar(50) = '',
@SoKS nvarchar(50) = '',
@Ten nvarchar(100) = '',
@TenBS nvarchar(200) = '',
@TienKham money = 0,
@TrangThai varchar(2) = '',
@TTBanDau nvarchar(500) = '',
@Tuoi float = -1,
@User_Add nvarchar(50) = '',
@User_Up nvarchar(50) = '',
@Sys_Stamp varchar(200) output

As

BEGIN

   If(@Action = 'Add')
   Begin
       Insert Into HP_BenhNhan
      (
       BacSiID,BenhNhanID,CanNang,ChieuCao,ChiNhanhID,Date_Add,Date_Up,DenPhong,DiaChi,DienGiai,DienThoai,DoiTuongKham,GioiTinh,HanSDDen,HanSDTu,HoTenLot,HoVaTen,HuyetAp,LoaiTuoi,Mach,MaSoTheKCB,NgayKCB,NgaySinh,NgheNghiepID,NhietDo,NhipTho,NoiDKKCB,PhongID,QuanHeID,Scrn_Add,Scrn_Up,SoCM,SoKS,Ten,TenBS,TienKham,TrangThai,TTBanDau,Tuoi,User_Add,User_Up
      )       Values
        (
     @BacSiID,@BenhNhanID,@CanNang,@ChieuCao,@ChiNhanhID,@Date_Add,@Date_Up,@DenPhong,@DiaChi,@DienGiai,@DienThoai,@DoiTuongKham,@GioiTinh,@HanSDDen,@HanSDTu,@HoTenLot,@HoVaTen,@HuyetAp,@LoaiTuoi,@Mach,@MaSoTheKCB,@NgayKCB,@NgaySinh,@NgheNghiepID,@NhietDo,@NhipTho,@NoiDKKCB,@PhongID,@QuanHeID,@Scrn_Add,@Scrn_Up,@SoCM,@SoKS,@Ten,@TenBS,@TienKham,@TrangThai,@TTBanDau,@Tuoi,@User_Add,@User_Up
        )       If @@ROWCOUNT = 1
       Begin
           Select @Sys_Stamp =  master.dbo.fn_varbintohexstr(Sys_Stamp) from HP_BenhNhan where BenhNhanID = @BenhNhanID
       End
   End
   If(@Action = 'Update')
   Begin
       Update HP_BenhNhan Set BacSiID = @BacSiID,BenhNhanID = @BenhNhanID,CanNang = @CanNang,ChieuCao = @ChieuCao,ChiNhanhID = @ChiNhanhID,Date_Add = @Date_Add,Date_Up = @Date_Up,DenPhong = @DenPhong,DiaChi = @DiaChi,DienGiai = @DienGiai,DienThoai = @DienThoai,DoiTuongKham = @DoiTuongKham,GioiTinh = @GioiTinh,HanSDDen = @HanSDDen,HanSDTu = @HanSDTu,HoTenLot = @HoTenLot,HoVaTen = @HoVaTen,HuyetAp = @HuyetAp,LoaiTuoi = @LoaiTuoi,Mach = @Mach,MaSoTheKCB = @MaSoTheKCB,NgayKCB = @NgayKCB,NgaySinh = @NgaySinh,NgheNghiepID = @NgheNghiepID,NhietDo = @NhietDo,NhipTho = @NhipTho,NoiDKKCB = @NoiDKKCB,PhongID = @PhongID,QuanHeID = @QuanHeID,Scrn_Add = @Scrn_Add,Scrn_Up = @Scrn_Up,SoCM = @SoCM,SoKS = @SoKS,Ten = @Ten,TenBS = @TenBS,TienKham = @TienKham,TrangThai = @TrangThai,TTBanDau = @TTBanDau,Tuoi = @Tuoi,User_Add = @User_Add,User_Up = @User_Up       where BenhNhanID = @BenhNhanID
       If @@ROWCOUNT = 1
       Begin
           Select @Sys_Stamp =  master.dbo.fn_varbintohexstr(Sys_Stamp) from HP_BenhNhan where BenhNhanID = @BenhNhanID
       End
   End
   If(@Action = 'UpdateAll')
   Begin
       Update HP_BenhNhan Set BacSiID = @BacSiID,BenhNhanID = @BenhNhanID,CanNang = @CanNang,ChieuCao = @ChieuCao,ChiNhanhID = @ChiNhanhID,Date_Add = @Date_Add,Date_Up = @Date_Up,DenPhong = @DenPhong,DiaChi = @DiaChi,DienGiai = @DienGiai,DienThoai = @DienThoai,DoiTuongKham = @DoiTuongKham,GioiTinh = @GioiTinh,HanSDDen = @HanSDDen,HanSDTu = @HanSDTu,HoTenLot = @HoTenLot,HoVaTen = @HoVaTen,HuyetAp = @HuyetAp,LoaiTuoi = @LoaiTuoi,Mach = @Mach,MaSoTheKCB = @MaSoTheKCB,NgayKCB = @NgayKCB,NgaySinh = @NgaySinh,NgheNghiepID = @NgheNghiepID,NhietDo = @NhietDo,NhipTho = @NhipTho,NoiDKKCB = @NoiDKKCB,PhongID = @PhongID,QuanHeID = @QuanHeID,Scrn_Add = @Scrn_Add,Scrn_Up = @Scrn_Up,SoCM = @SoCM,SoKS = @SoKS,Ten = @Ten,TenBS = @TenBS,TienKham = @TienKham,TrangThai = @TrangThai,TTBanDau = @TTBanDau,Tuoi = @Tuoi,User_Add = @User_Add,User_Up = @User_Up       where BenhNhanID like @BenhNhanID
   End
   If(@Action = 'Delete')
   Begin
       Delete HP_BenhNhan where BenhNhanID = @BenhNhanID
   End
   If(@Action = 'DeleteAll')
   Begin
       Delete HP_BenhNhan where BenhNhanID like @BenhNhanID
   End
   If(@Action = 'GetAll')
   Begin
       Select  BacSiID,BenhNhanID,CanNang,ChieuCao,ChiNhanhID,Date_Add,Date_Up,DenPhong,DiaChi,DienGiai,DienThoai,DoiTuongKham,GioiTinh,HanSDDen,HanSDTu,HoTenLot,HoVaTen,HuyetAp,LoaiTuoi,Mach,MaSoTheKCB,NgayKCB,NgaySinh,NgheNghiepID,NhietDo,NhipTho,NoiDKKCB,PhongID,QuanHeID,Scrn_Add,Scrn_Up,SoCM,SoKS,Sys_Stamp = master.dbo.fn_varbintohexstr(Sys_Stamp),Ten,TenBS,TienKham,TrangThai,TTBanDau,Tuoi,User_Add,User_Up, IsChange = 0 from HP_BenhNhan where BenhNhanID like @BenhNhanID
   End
   If(@Action = 'GetByKey')
   Begin
       Select  BacSiID,BenhNhanID,CanNang,ChieuCao,ChiNhanhID,Date_Add,Date_Up,DenPhong,DiaChi,DienGiai,DienThoai,DoiTuongKham,GioiTinh,HanSDDen,HanSDTu,HoTenLot,HoVaTen,HuyetAp,LoaiTuoi,Mach,MaSoTheKCB,NgayKCB,NgaySinh,NgheNghiepID,NhietDo,NhipTho,NoiDKKCB,PhongID,QuanHeID,Scrn_Add,Scrn_Up,SoCM,SoKS,Sys_Stamp = master.dbo.fn_varbintohexstr(Sys_Stamp),Ten,TenBS,TienKham,TrangThai,TTBanDau,Tuoi,User_Add,User_Up, IsChange = 0 from HP_BenhNhan where BenhNhanID = @BenhNhanID
   End
END
GO




IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[prc_HP_Phieu]') AND type in (N'P', N'PC'))
   DROP PROCEDURE [dbo].[prc_HP_Phieu]

GO


Create Proc prc_HP_Phieu

@Action varchar(200) = '',
@ABPhieu varchar(50) = '',
@ARPhieu varchar(50) = '',
@BacSiID varchar(50) = '',
@BenhNhanID varchar(50) = '',
@CanNang float = -1,
@CapThuoc int = -1,
@CapTK varchar(10) = '',
@CapTKCoTienKham varchar(10) = '',
@CapTKNoTienKham varchar(10) = '',
@CheDoAn nvarchar(200) = '',
@CheDoAnQT nvarchar(200) = '',
@ChietKhau money = 0,
@ChieuCao float = -1,
@ChiNhanhID varchar(50) = '',
@ChiPhi money = 0,
@ChuanDoan nvarchar(200) = '',
@ChuanDoanID varchar(50) = '',
@ChuyenDen nvarchar(200) = '',
@CPPhieu varchar(50) = '',
@CPPhieu1 varchar(50) = '',
@CPPhieu2 varchar(50) = '',
@CPPhieu3 varchar(50) = '',
@CPPhieu4 varchar(50) = '',
@CPPhieu5 varchar(50) = '',
@CPPhieu6 varchar(50) = '',
@CPPhieu7 varchar(50) = '',
@CPPhieu8 varchar(50) = '',
@DanKhac nvarchar(200) = '',
@DanKhacQT nvarchar(200) = '',
@Date_Add smalldatetime = '2011/03/15',
@Date_Up smalldatetime = '2011/03/15',
@DenTienTe varchar(50) = '',
@DiaChi nvarchar(200) = '',
@DiaChiCD nvarchar(200) = '',
@DienGiai nvarchar(200) = '',
@DoiTuong nvarchar(200) = '',
@DoiTuongID varchar(50) = '',
@DoiTuongKham varchar(5) = '',
@DongKy smallint = -1,
@DVToa varchar(1) = '',
@DVToaQT varchar(1) = '',
@GioKham varchar(50) = '',
@GioQuayThuoc varchar(50) = '',
@HPPhieu varchar(50) = '',
@HuyetAp varchar(50) = '',
@KhuyenMai money = 0,
@KyID varchar(50) = '',
@LoaiCT varchar(5) = '',
@LyDoCD nvarchar(200) = '',
@LyDoTuPhong nvarchar(200) = '',
@Mach float = -1,
@NgayCT datetime = '2011/03/15',
@NgayKham datetime = '2011/03/15',
@NgayTT datetime = '2011/03/15',
@NhietDo float = -1,
@NhipTho float = -1,
@PhepToan varchar(1) = '',
@PhieuID varchar(50) = '',
@PhongID varchar(50) = '',
@QuayThuoc varchar(50) = '',
@QuayThuocIn int = -1,
@Scrn_Add nvarchar(50) = '',
@Scrn_Up nvarchar(50) = '',
@SinhHoat nvarchar(200) = '',
@SinhHoatQT nvarchar(200) = '',
@SoTien money = 0,
@TaiKham int = -1,
@TaiKhoan varchar(10) = '',
@TenBS nvarchar(200) = '',
@Thue money = 0,
@TienKham money = 0,
@TKCoTienKham varchar(10) = '',
@TKNoTienKham varchar(10) = '',
@ToaThuoc int = -1,
@ToaThuocQT int = -1,
@TrangThai int = -1,
@TuPhong varchar(50) = '',
@TuTienTe varchar(50) = '',
@TyGia float = -1,
@User_Add nvarchar(50) = '',
@User_Up nvarchar(50) = '',
@WFPhieu varchar(50) = '',
@WHPhieu varchar(50) = '',
@XNChuyenPhong int = -1,
@XuLy varchar(5) = '',
@Sys_Stamp varchar(200) output

As

BEGIN

   If(@Action = 'Add')
   Begin
       Insert Into HP_Phieu
      (
       ABPhieu,ARPhieu,BacSiID,BenhNhanID,CanNang,CapThuoc,CapTK,CapTKCoTienKham,CapTKNoTienKham,CheDoAn,CheDoAnQT,ChietKhau,ChieuCao,ChiNhanhID,ChiPhi,ChuanDoan,ChuanDoanID,ChuyenDen,CPPhieu,CPPhieu1,CPPhieu2,CPPhieu3,CPPhieu4,CPPhieu5,CPPhieu6,CPPhieu7,CPPhieu8,DanKhac,DanKhacQT,Date_Add,Date_Up,DenTienTe,DiaChi,DiaChiCD,DienGiai,DoiTuong,DoiTuongID,DoiTuongKham,DongKy,DVToa,DVToaQT,GioKham,GioQuayThuoc,HPPhieu,HuyetAp,KhuyenMai,KyID,LoaiCT,LyDoCD,LyDoTuPhong,Mach,NgayCT,NgayKham,NgayTT,NhietDo,NhipTho,PhepToan,PhieuID,PhongID,QuayThuoc,QuayThuocIn,Scrn_Add,Scrn_Up,SinhHoat,SinhHoatQT,SoTien,TaiKham,TaiKhoan,TenBS,Thue,TienKham,TKCoTienKham,TKNoTienKham,ToaThuoc,ToaThuocQT,TrangThai,TuPhong,TuTienTe,TyGia,User_Add,User_Up,WFPhieu,WHPhieu,XNChuyenPhong,XuLy
      )       Values
        (
     @ABPhieu,@ARPhieu,@BacSiID,@BenhNhanID,@CanNang,@CapThuoc,@CapTK,@CapTKCoTienKham,@CapTKNoTienKham,@CheDoAn,@CheDoAnQT,@ChietKhau,@ChieuCao,@ChiNhanhID,@ChiPhi,@ChuanDoan,@ChuanDoanID,@ChuyenDen,@CPPhieu,@CPPhieu1,@CPPhieu2,@CPPhieu3,@CPPhieu4,@CPPhieu5,@CPPhieu6,@CPPhieu7,@CPPhieu8,@DanKhac,@DanKhacQT,@Date_Add,@Date_Up,@DenTienTe,@DiaChi,@DiaChiCD,@DienGiai,@DoiTuong,@DoiTuongID,@DoiTuongKham,@DongKy,@DVToa,@DVToaQT,@GioKham,@GioQuayThuoc,@HPPhieu,@HuyetAp,@KhuyenMai,@KyID,@LoaiCT,@LyDoCD,@LyDoTuPhong,@Mach,@NgayCT,@NgayKham,@NgayTT,@NhietDo,@NhipTho,@PhepToan,@PhieuID,@PhongID,@QuayThuoc,@QuayThuocIn,@Scrn_Add,@Scrn_Up,@SinhHoat,@SinhHoatQT,@SoTien,@TaiKham,@TaiKhoan,@TenBS,@Thue,@TienKham,@TKCoTienKham,@TKNoTienKham,@ToaThuoc,@ToaThuocQT,@TrangThai,@TuPhong,@TuTienTe,@TyGia,@User_Add,@User_Up,@WFPhieu,@WHPhieu,@XNChuyenPhong,@XuLy
        )       If @@ROWCOUNT = 1
       Begin
           Select @Sys_Stamp =  master.dbo.fn_varbintohexstr(Sys_Stamp) from HP_Phieu where ChiNhanhID = @ChiNhanhID And PhieuID = @PhieuID
       End
   End
   If(@Action = 'Update')
   Begin
       Update HP_Phieu Set ABPhieu = @ABPhieu,ARPhieu = @ARPhieu,BacSiID = @BacSiID,BenhNhanID = @BenhNhanID,CanNang = @CanNang,CapThuoc = @CapThuoc,CapTK = @CapTK,CapTKCoTienKham = @CapTKCoTienKham,CapTKNoTienKham = @CapTKNoTienKham,CheDoAn = @CheDoAn,CheDoAnQT = @CheDoAnQT,ChietKhau = @ChietKhau,ChieuCao = @ChieuCao,ChiNhanhID = @ChiNhanhID,ChiPhi = @ChiPhi,ChuanDoan = @ChuanDoan,ChuanDoanID = @ChuanDoanID,ChuyenDen = @ChuyenDen,CPPhieu = @CPPhieu,CPPhieu1 = @CPPhieu1,CPPhieu2 = @CPPhieu2,CPPhieu3 = @CPPhieu3,CPPhieu4 = @CPPhieu4,CPPhieu5 = @CPPhieu5,CPPhieu6 = @CPPhieu6,CPPhieu7 = @CPPhieu7,CPPhieu8 = @CPPhieu8,DanKhac = @DanKhac,DanKhacQT = @DanKhacQT,Date_Add = @Date_Add,Date_Up = @Date_Up,DenTienTe = @DenTienTe,DiaChi = @DiaChi,DiaChiCD = @DiaChiCD,DienGiai = @DienGiai,DoiTuong = @DoiTuong,DoiTuongID = @DoiTuongID,DoiTuongKham = @DoiTuongKham,DongKy = @DongKy,DVToa = @DVToa,DVToaQT = @DVToaQT,GioKham = @GioKham,GioQuayThuoc = @GioQuayThuoc,HPPhieu = @HPPhieu,HuyetAp = @HuyetAp,KhuyenMai = @KhuyenMai,KyID = @KyID,LoaiCT = @LoaiCT,LyDoCD = @LyDoCD,LyDoTuPhong = @LyDoTuPhong,Mach = @Mach,NgayCT = @NgayCT,NgayKham = @NgayKham,NgayTT = @NgayTT,NhietDo = @NhietDo,NhipTho = @NhipTho,PhepToan = @PhepToan,PhieuID = @PhieuID,PhongID = @PhongID,QuayThuoc = @QuayThuoc,QuayThuocIn = @QuayThuocIn,Scrn_Add = @Scrn_Add,Scrn_Up = @Scrn_Up,SinhHoat = @SinhHoat,SinhHoatQT = @SinhHoatQT,SoTien = @SoTien,TaiKham = @TaiKham,TaiKhoan = @TaiKhoan,TenBS = @TenBS,Thue = @Thue,TienKham = @TienKham,TKCoTienKham = @TKCoTienKham,TKNoTienKham = @TKNoTienKham,ToaThuoc = @ToaThuoc,ToaThuocQT = @ToaThuocQT,TrangThai = @TrangThai,TuPhong = @TuPhong,TuTienTe = @TuTienTe,TyGia = @TyGia,User_Add = @User_Add,User_Up = @User_Up,WFPhieu = @WFPhieu,WHPhieu = @WHPhieu,XNChuyenPhong = @XNChuyenPhong,XuLy = @XuLy       where ChiNhanhID = @ChiNhanhID And PhieuID = @PhieuID
       If @@ROWCOUNT = 1
       Begin
           Select @Sys_Stamp =  master.dbo.fn_varbintohexstr(Sys_Stamp) from HP_Phieu where ChiNhanhID = @ChiNhanhID And PhieuID = @PhieuID
       End
   End
   If(@Action = 'UpdateAll')
   Begin
       Update HP_Phieu Set ABPhieu = @ABPhieu,ARPhieu = @ARPhieu,BacSiID = @BacSiID,BenhNhanID = @BenhNhanID,CanNang = @CanNang,CapThuoc = @CapThuoc,CapTK = @CapTK,CapTKCoTienKham = @CapTKCoTienKham,CapTKNoTienKham = @CapTKNoTienKham,CheDoAn = @CheDoAn,CheDoAnQT = @CheDoAnQT,ChietKhau = @ChietKhau,ChieuCao = @ChieuCao,ChiNhanhID = @ChiNhanhID,ChiPhi = @ChiPhi,ChuanDoan = @ChuanDoan,ChuanDoanID = @ChuanDoanID,ChuyenDen = @ChuyenDen,CPPhieu = @CPPhieu,CPPhieu1 = @CPPhieu1,CPPhieu2 = @CPPhieu2,CPPhieu3 = @CPPhieu3,CPPhieu4 = @CPPhieu4,CPPhieu5 = @CPPhieu5,CPPhieu6 = @CPPhieu6,CPPhieu7 = @CPPhieu7,CPPhieu8 = @CPPhieu8,DanKhac = @DanKhac,DanKhacQT = @DanKhacQT,Date_Add = @Date_Add,Date_Up = @Date_Up,DenTienTe = @DenTienTe,DiaChi = @DiaChi,DiaChiCD = @DiaChiCD,DienGiai = @DienGiai,DoiTuong = @DoiTuong,DoiTuongID = @DoiTuongID,DoiTuongKham = @DoiTuongKham,DongKy = @DongKy,DVToa = @DVToa,DVToaQT = @DVToaQT,GioKham = @GioKham,GioQuayThuoc = @GioQuayThuoc,HPPhieu = @HPPhieu,HuyetAp = @HuyetAp,KhuyenMai = @KhuyenMai,KyID = @KyID,LoaiCT = @LoaiCT,LyDoCD = @LyDoCD,LyDoTuPhong = @LyDoTuPhong,Mach = @Mach,NgayCT = @NgayCT,NgayKham = @NgayKham,NgayTT = @NgayTT,NhietDo = @NhietDo,NhipTho = @NhipTho,PhepToan = @PhepToan,PhieuID = @PhieuID,PhongID = @PhongID,QuayThuoc = @QuayThuoc,QuayThuocIn = @QuayThuocIn,Scrn_Add = @Scrn_Add,Scrn_Up = @Scrn_Up,SinhHoat = @SinhHoat,SinhHoatQT = @SinhHoatQT,SoTien = @SoTien,TaiKham = @TaiKham,TaiKhoan = @TaiKhoan,TenBS = @TenBS,Thue = @Thue,TienKham = @TienKham,TKCoTienKham = @TKCoTienKham,TKNoTienKham = @TKNoTienKham,ToaThuoc = @ToaThuoc,ToaThuocQT = @ToaThuocQT,TrangThai = @TrangThai,TuPhong = @TuPhong,TuTienTe = @TuTienTe,TyGia = @TyGia,User_Add = @User_Add,User_Up = @User_Up,WFPhieu = @WFPhieu,WHPhieu = @WHPhieu,XNChuyenPhong = @XNChuyenPhong,XuLy = @XuLy       where ChiNhanhID like @ChiNhanhID And PhieuID like @PhieuID
   End
   If(@Action = 'Delete')
   Begin
       Delete HP_Phieu where ChiNhanhID = @ChiNhanhID And PhieuID = @PhieuID
   End
   If(@Action = 'DeleteAll')
   Begin
       Delete HP_Phieu where ChiNhanhID like @ChiNhanhID And PhieuID like @PhieuID
   End
   If(@Action = 'GetAll')
   Begin
       Select  ABPhieu,ARPhieu,BacSiID,BenhNhanID,CanNang,CapThuoc,CapTK,CapTKCoTienKham,CapTKNoTienKham,CheDoAn,CheDoAnQT,ChietKhau,ChieuCao,ChiNhanhID,ChiPhi,ChuanDoan,ChuanDoanID,ChuyenDen,CPPhieu,CPPhieu1,CPPhieu2,CPPhieu3,CPPhieu4,CPPhieu5,CPPhieu6,CPPhieu7,CPPhieu8,DanKhac,DanKhacQT,Date_Add,Date_Up,DenTienTe,DiaChi,DiaChiCD,DienGiai,DoiTuong,DoiTuongID,DoiTuongKham,DongKy,DVToa,DVToaQT,GioKham,GioQuayThuoc,HPPhieu,HuyetAp,KhuyenMai,KyID,LoaiCT,LyDoCD,LyDoTuPhong,Mach,NgayCT,NgayKham,NgayTT,NhietDo,NhipTho,PhepToan,PhieuID,PhongID,QuayThuoc,QuayThuocIn,Scrn_Add,Scrn_Up,SinhHoat,SinhHoatQT,SoTien,Sys_Stamp = master.dbo.fn_varbintohexstr(Sys_Stamp),TaiKham,TaiKhoan,TenBS,Thue,TienKham,TKCoTienKham,TKNoTienKham,ToaThuoc,ToaThuocQT,TrangThai,TuPhong,TuTienTe,TyGia,User_Add,User_Up,WFPhieu,WHPhieu,XNChuyenPhong,XuLy, IsChange = 0 from HP_Phieu where ChiNhanhID like @ChiNhanhID And PhieuID like @PhieuID
   End
   If(@Action = 'GetByKey')
   Begin
       Select  ABPhieu,ARPhieu,BacSiID,BenhNhanID,CanNang,CapThuoc,CapTK,CapTKCoTienKham,CapTKNoTienKham,CheDoAn,CheDoAnQT,ChietKhau,ChieuCao,ChiNhanhID,ChiPhi,ChuanDoan,ChuanDoanID,ChuyenDen,CPPhieu,CPPhieu1,CPPhieu2,CPPhieu3,CPPhieu4,CPPhieu5,CPPhieu6,CPPhieu7,CPPhieu8,DanKhac,DanKhacQT,Date_Add,Date_Up,DenTienTe,DiaChi,DiaChiCD,DienGiai,DoiTuong,DoiTuongID,DoiTuongKham,DongKy,DVToa,DVToaQT,GioKham,GioQuayThuoc,HPPhieu,HuyetAp,KhuyenMai,KyID,LoaiCT,LyDoCD,LyDoTuPhong,Mach,NgayCT,NgayKham,NgayTT,NhietDo,NhipTho,PhepToan,PhieuID,PhongID,QuayThuoc,QuayThuocIn,Scrn_Add,Scrn_Up,SinhHoat,SinhHoatQT,SoTien,Sys_Stamp = master.dbo.fn_varbintohexstr(Sys_Stamp),TaiKham,TaiKhoan,TenBS,Thue,TienKham,TKCoTienKham,TKNoTienKham,ToaThuoc,ToaThuocQT,TrangThai,TuPhong,TuTienTe,TyGia,User_Add,User_Up,WFPhieu,WHPhieu,XNChuyenPhong,XuLy, IsChange = 0 from HP_Phieu where ChiNhanhID = @ChiNhanhID And PhieuID = @PhieuID
   End
END
GO




